export default {
  data() {
    return {
      statusBarHeight: 0,
      safeAreaInsetsBottom: 0,
      keyboardHeight: 0,
      keyboardTop: 0,
    };
  },
  mounted() {
    // #ifndef H5 || APP-PLUS
    let { statusBarHeight, safeArea, screenHeight } = uni.getWindowInfo();
    this.safeAreaInsetsBottom = screenHeight - safeArea.height - statusBarHeight;
    this.statusBarHeight = statusBarHeight || uni.getMenuButtonBoundingClientRect().top || 0;
    // #endif
  },
  methods: {
    rmZeros(str) {
      return String(str).replace(/(\.\d*?[1-9])0+$|\.0+$/, '$1');
    },
    absNumber(str) {
      return Math.abs(str);
    },
    isObject(value) {
      return Object.prototype.toString.call(value) === '[object Object]';
    },
    isEmpty(value) {
    switch (typeof value) {
    case 'undefined':
        return true
    case 'string':
        if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true
        break
    case 'boolean':
        if (!value) return true
        break
    case 'number':
        if (value === 0 || isNaN(value)) return true
        break
    case 'object':
        if (value === null || value.length === 0) return true
        for (const i in value) {
            return false
        }
        return true
    }
    return false
},
    handleCopy(content) {
      uni.setClipboardData({
        data: content,
        success: () => {
          uni.showToast({ title: '复制成功',  icon: 'none', duration: 2000, }); },
        fail: (err) => {
          uni.showToast({ title: err, icon: 'none',  duration: 2000, });
        },
      });
    },
  },
};
